package io.filecopy;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

//用字节输入输出流实现文件复制
public class Demo01 {
    public static void main(String[] args) throws Exception {
        File file1 = new File("F://Test//T1//a.txt");
        File file2 = new File("F://Test//T1//a2.txt");
        FileInputStream fileInputStream = new FileInputStream(file1);
        FileOutputStream fileOutputStream = new FileOutputStream(file2);
        byte[] bytes = new byte[1024];
        int length = 0;

        while ((length = fileInputStream.read(bytes)) != -1) {
            fileOutputStream.write(bytes);
        }

        fileOutputStream.flush();
    }
}
